﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace dzs.Web.supply
{
    public partial class AddComplateSupplyPlan : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["supplyPlanId"]))
                {
                    string supplyPlanId = Request["supplyPlanId"];

                    DataSet ds = new Maticsoft.BLL.supplyPlan().GetList(" supplyPlanId="+supplyPlanId);

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        this.lbl_proid.Text = ds.Tables[0].Rows[0]["proid"].ToString();
                        this.lbl_projectname.Text = ds.Tables[0].Rows[0]["projectName"].ToString();

                         Bind(lbl_proid.Text);
                    }
                   
                }
            }
        }

        

        //安装调试确认
        protected void btn_tsqr_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["supplyPlanId"]))
            {
                if (!string.IsNullOrEmpty(this.txt_installationStatusDate.Text))
                {
                    string supplyPlanId = Request["supplyPlanId"];

                    Maticsoft.BLL.supplyPlan sm = new Maticsoft.BLL.supplyPlan();
                    Maticsoft.Model.supplyPlan s = sm.GetModel(int.Parse(supplyPlanId));

                    s.installationStatus = "已确认";
                    s.installationStatusDate = DateTime.Parse(this.txt_installationStatusDate.Text);

                    if (sm.Update(s))
                    {
                        Maticsoft.Common.MessageBox.Show(this, "安装调试已确认！");
                    }

                }
               
            }
        }
        //安装调试发送质量计划
        protected void btn_tszljh_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txt_installationStatusDate.Text))
            {
                string supplyPlanId = Request["supplyPlanId"];

                DataSet ds = new Maticsoft.BLL.supplyPlan().GetListSumInnumsInfo(" supplyPlanId="+supplyPlanId);

                dzs.BLL.tempskd tm = new BLL.tempskd();//临时质量计划表

                dzs.Model.tempskd t = new Model.tempskd();
                t.material = ds.Tables[0].Rows[0]["material"].ToString();
                //t.monthSupplyPlanId = int.Parse(monthSupplyPlanId);
                t.project = ds.Tables[0].Rows[0]["projectName"].ToString();
                t.tdate = DateTime.Now;
                t.ttype = "安装调试确认";

                if (tm.Add(t) > 0)
                {
                    Maticsoft.Common.MessageBox.Show(this, "添加安装调试确认质量计划成功！");
                }
                
            }
          
        }
        //投运确认
        protected void btn_tyqr_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["supplyPlanId"]))
            {
                if (!string.IsNullOrEmpty(this.txt_installationStatusDate.Text))
                {
                    string supplyPlanId = Request["supplyPlanId"];

                    Maticsoft.BLL.supplyPlan sm = new Maticsoft.BLL.supplyPlan();
                    Maticsoft.Model.supplyPlan s = sm.GetModel(int.Parse(supplyPlanId));

                    s.putOperationStatus = "已确认";
                    s.putOperationStatusDate = DateTime.Parse(this.txt_putOperationStatusDate.Text);

                    if (sm.Update(s))
                    {
                        Maticsoft.Common.MessageBox.Show(this, "投运确认状态已确认！");
                    }

                }

            }
        }

        //投运确认质量计划
        protected void btn_tyqrzljh_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txt_installationStatusDate.Text))
            {
                string supplyPlanId = Request["supplyPlanId"];

                DataSet ds = new Maticsoft.BLL.supplyPlan().GetListSumInnumsInfo(" supplyPlanId=" + supplyPlanId);

                dzs.BLL.tempskd tm = new BLL.tempskd();//临时质量计划表

                dzs.Model.tempskd t = new Model.tempskd();
                t.material = ds.Tables[0].Rows[0]["material"].ToString();
                //t.monthSupplyPlanId = int.Parse(monthSupplyPlanId);
                t.project = ds.Tables[0].Rows[0]["projectName"].ToString();
                t.tdate = DateTime.Now;
                t.ttype = "投运确认";

                if (tm.Add(t) > 0)
                {
                    Maticsoft.Common.MessageBox.Show(this, "添加投运确认质量计划成功！");
                }

            }
          
        }
        //投运评价确认
        protected void btn_typjqr_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["supplyPlanId"]))
            {
                if (!string.IsNullOrEmpty(this.txt_installationStatusDate.Text))
                {
                    string supplyPlanId = Request["supplyPlanId"];

                    Maticsoft.BLL.supplyPlan sm = new Maticsoft.BLL.supplyPlan();
                    Maticsoft.Model.supplyPlan s = sm.GetModel(int.Parse(supplyPlanId));

                    s.putOperationEvaluationStaus = "已确认";
                    s.putOperationEvaluationStausDate = DateTime.Parse(this.txt_putOperationEvaluationStausDate.Text);

                    if (sm.Update(s))
                    {
                        Maticsoft.Common.MessageBox.Show(this, "投运评价状态已确认！");
                    }

                }

            }
        }

        private void Bind(string proid)
        {
            DataSet ds = new dzs.BLL.inventory().GetListMaterialInventoryProject(" proid='"+proid+"' ");

            this.GridView1.DataSource = ds;
            this.GridView1.DataBind();
        }
    }
}